package at.fhhagenberg.hydrac.java.sample.ast;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.CompilationUnit;

public class Parser {

	private static AST ast;

	public static void main(String[] args) {
		ast = AST.newAST(AST.JLS3);

		String sourceCode = "package codegen.sample;\r\n" +
				"public class SumCalculator {\r\n" +
				"\r\n" +
				"	public static void main(String[] args) {\r\n" +
				"\r\n" +
				"		int[] argc = new int[] { 1, 2, 7, 1, 9, 4, 7 };\r\n" +
				"\r\n" +
				"		int min = Integer.MAX_VALUE;\r\n" +
				"		int max = Integer.MIN_VALUE;\r\n" +
				"		int i;\r\n" +
				"\r\n" +
				"		for (i = 1; i < argc.length; i++) {\r\n" +
				"			int val = argc[i];\r\n" +
				"			if (val > max) {\r\n" +
				"				max = val;\r\n" +
				"			}\r\n" +
				"			if (val < min) {\r\n" +
				"				min = val;\r\n" +
				"			}\r\n" +
				"		}\r\n" +
				"\r\n" +
				"		System.out.println(\"minimum = \" + min + \" maximum = \" + max + \"\\n\");\r\n" +
				"\r\n" +
				"	}\r\n" +
				"\r\n" +
				"}\r\n" +
				"";


		CompilationUnit cu = AST.parseCompilationUnit(sourceCode.toCharArray());

		System.out.println(cu);

	}

}
